package com.hz.userservice.mapper;

import com.hz.userservice.model.entity.ClassEntity;
import com.hz.userservice.model.entity.GradeEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassMapper {
    @Insert("insert into classes values (null,#{class_name},#{grade_id},#{grade_name},#{grade_year})")
    public int addClass(ClassEntity classEntity);

    @Delete("delete from classes where id = #{classId}")
    public int deleteClass(@Param("id")int classId);

    @Select("select * from classes where grade_id = #{gradeId}")
    public List<ClassEntity> gradeClasses(@Param("gradeId") int gradeId);

    @Select("select * from classes where class_name = #{className};")
    public ClassEntity findByClassName(@Param("className") String className);

    @Select("select * from classes where id = #{classId};")
    public ClassEntity findByClassId(@Param("classId") Integer classId);
}
